package com.hup.minicontroller.common.constant;

public abstract class NetConstant {

    /**
     * 局域网服务端的端口号
     */
    public static final int LAN_SERVER_PORT = 8887;
    /**
     * 帧率
     */
    public static final int[] FPS = new int[]{15, 25, 30, 50, 60, 70};
    /**
     * 图像大小:长边的像素
     */
    public static final int[] SCREEN_SIZE = new int[]{256, 512, 768, 1024, 2048};
    /**
     * 图像质量
     */
    public static final int[] SCREEN_QUALITY = new int[]{10, 25, 50, 70, 80, 90, 100};

    public static final int DEFAULT_FPS_INDEX = 3;
    /**
     * 分辨率:减小后可以减小数据量,但比较影响文字阅读,不建议降低分辨率(除非原图是2k,4k)
     */
    public static final int DEFAULT_SCREEN_SIZE_INDEX = 2;
    /**
     * 图像质量:控制数据量的关键参数;
     * .质量取值10到100,数据量的增长曲线是"指数型的"
     * .90比100,数据量减小了接近一半;但往后降低质量,数据量降幅逐渐变小
     * .质量即使为10,也不影响文字阅读,只是图像变得有波纹
     */
    public static final int DEFAULT_SCREEN_QUALITY_INDEX = 3;

    public static int getSafeFps(int fps) {
        for (int v : FPS) if (v == fps) return v;
        return FPS[DEFAULT_FPS_INDEX];
    }

    public static int getSafeScreenSize(int screenSize) {
        for (int v : SCREEN_SIZE) if (v == screenSize) return v;
        return SCREEN_SIZE[DEFAULT_SCREEN_SIZE_INDEX];
    }

    public static int getSafeScreenQuality(int screenQuality) {
        for (int v : SCREEN_QUALITY) if (v == screenQuality) return v;
        return SCREEN_QUALITY[DEFAULT_SCREEN_QUALITY_INDEX];
    }

    /**
     * 连接方式
     */
    public enum ConnectType {
        LAN("局域网"),
        BLUETOOTH("蓝牙");

        public final String desc;

        ConnectType(String desc) {
            this.desc = desc;
        }
    }

    /**
     * socket传输时的帧数据类型
     */
    public interface DataType {
        int CONTROL_CONFIG = 201;
        int SCREEN_DATA = 202;
        int FUNCTION_BUTTON = 203;
        int FULL_SCREEN_TOUCH = 204;
        int TOUCH_PAD_TOUCH = 205;
    }

}
